<template>
	<view class="content">
		<u-cell-group>
			<u-cell-item icon="level" title="好友ID" :arrow="false" :value="id"></u-cell-item>
			<u-cell-item icon="account" title="好友名称" :arrow="false" :value="name"></u-cell-item>
			<u-cell-item icon="camera" title="好友头像" :arrow="false">
				<u-avatar :src="$store.state.common.systemInfo.fileurl + 'avatar/' + id + '.jpg'" slot="right-icon"
					size="40"></u-avatar>
			</u-cell-item>

		</u-cell-group>

		<u-gap height="10" bg-color="#bbb"></u-gap>

		<view @click="laheiuser" class="gitemc">
			<image src="/static/images/lahei.png" style="width: 43rpx;height: 43rpx;" mode=""></image>
			<view style="margin-left: 15rpx;color: #de7d75;">
				拉黑好友
			</view>
		</view>

		<view style="">
			<u-gap height="1" bg-color="#ececec"></u-gap>
		</view>

		<view @click="deluser" class="gitemc">
			<image src="/static/images/delete.png" style="width: 43rpx;height: 43rpx;" mode=""></image>
			<view style="margin-left: 15rpx;color: #de7d75;">
				删除好友
			</view>
		</view>
	</view>


</template>

<script>
	import {
		mapState
	} from 'vuex';
	import {
		pub
	} from '../../common/event';
	export default {
		data() {
			return {
				id: '',
				name: ''
			}
		},
		components: {

		},
		computed: {
			...mapState({
				list: (state) => {
					return state.friend.list
				}
			})
		},

		onLoad({
			id,
			name
		}) {
			this.id = id
			this.name = name
		},
		methods: {
			laheiuser: async function() {
				const user = this.$store.state.user.user
				const ret = await this.$u.put(`friend/friend/laheiuser`, {
					fid: this.id,
					uid: user.id
				})
				this.$store.commit(`friend/laheiuser`, {
					fid: this.id,
					uid: user.id
				})
				uni.switchTab({
					url: "/pages/friend/index"
				})
			},
			deluser: async function() {
				const user = this.$store.state.user.user
				const id = this.id
				const ret = await this.$u.delete(`friend/friend/deluser/${user.id}/${id}`)
				this.$store.commit(`friend/deluser`, {
					fid: this.id,
					uid: user.id
				})
				uni.switchTab({
					url: "/pages/friend/index"
				})
			},
		}
	}
</script>


<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 100%;
		height: 100vh;
		overflow-y: hidden;
		padding-bottom: 120rpx;
	}

	.gitemc {
		width: 100%;
		padding: 30rpx;
		background: #fafafa;
		display: flex;
		align-items: center;
		justify-content: center;
		font-weight: bold;
		color: #2f5f8f;
		font-size: 32rpx;
	}
</style>